package com.ghsc.ghxc.jsb.ui.live.view.cust

import android.view.LayoutInflater
import com.cn.appcore.ext.*
import com.cn.appcore.utils.GlideUtil
import com.ghsc.ghxc.jsb.R
import com.ghsc.ghxc.jsb.databinding.ImCustGifViewBinding
import com.netease.yunxin.kit.chatkit.ui.databinding.ChatBaseMessageViewHolderBinding
import com.netease.yunxin.kit.chatkit.ui.model.ChatMessageBean
import com.netease.yunxin.kit.chatkit.ui.normal.view.message.viewholder.NormalChatBaseMessageViewHolder

/**
 * 项目：GuoHuaMall
 * 包名：com.ghsc.ghxc.ui.message.yunxin.view
 * 类名：CusRedAttachmentViewHolder
 * 创建时间：2023/10/24 21:10
 * 创建人 @author： xiaolin
 * 描述 ：Todo...礼物
 */
class CusGifAttachmentViewHolder(parent: ChatBaseMessageViewHolderBinding, viewType: Int) : NormalChatBaseMessageViewHolder(
    parent, viewType
) {

    private var binding //创建自己的layout布局
            : ImCustGifViewBinding? = null
    override fun addViewToMessageContainer() {
        binding = ImCustGifViewBinding.inflate(
            LayoutInflater.from(parent.context), messageContainer, true
        )
    }

    //去掉背景
    override fun onMessageBackgroundConfig(messageBean: ChatMessageBean?) {
        baseViewBinding.messageContainer.setBackgroundResource(R.color.title_transfer)
    }



    override fun bindData(message: ChatMessageBean?, lastMessage: ChatMessageBean?) {
        super.bindData(message, lastMessage)
        currentMessage = message
        val bean = message!!.messageData.message.attachment as CusGifAttachment
            ?: return
        binding?.let {
            it.tvGifName.text="送你"+bean.cnt+"个"+bean.name+"礼物"
            GlideUtil.ImageLoad(parent.context,bean.images,it.imgGif)
            it.llItem.setSingleClickListener {
//                RxBus.getDefault().post(
//                    RxBusBean(
//                        CustSignKey.CHAT_LIVE_URL,
//                        CustSignKey.CHAT_LIVE_URL, bean)
//                )
            }
        }

    }
}